package com.gf.gf_data.service.impl;

import com.gf.gf_data.dao.AccountDao;
import com.gf.gf_data.service.AccountService;
import com.gf.gf_data.entity.Account;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.Set;

@Service
public class AccountServiceImpl implements AccountService {

    @Autowired
    private AccountDao accountDao;

    @Transactional
    @Override
    public boolean regAccount(Account account) {
        return account != null && accountDao.insert(account) == 1;
    }

    @Override
    public Account findAccountByPhone(String phone, String areaCode) {
        return accountDao.selectByPhoneAndAreaCode(phone, areaCode);
    }

    @Override
    public Set<String> findRolesByToken(String token) {
        return accountDao.selectRoles(token);
    }

    @Override
    public Set<String> findPermissionsByToken(String token) {
        return accountDao.selectPermissions(token);
    }


}
